﻿using System.Dynamic;
using Basic.FormGatewaryModular.Interface;
using Basic.FormRemoteModel.FormView;
using Basic.FormRemoteModel.FormView.Model;
using Basic.FormRemoteModel.FormViewCol;
using Basic.FormRemoteModel.FormViewCol.Model;
using WeDonekRpc.Client;
using WeDonekRpc.HttpApiGateway.Model;

namespace Basic.FormGatewaryModular.Services
{
    internal class FormViewService : IFormViewService
    {
        public long Add ( FormViewAdd data )
        {
            return new AddFormView
            {
                Datum = data
            }.Send();
        }

        public void Delete ( long id )
        {
            new DeleteFormView
            {
                Id = id
            }.Send();
        }

        public FormViewDto Find ( long formId )
        {
            return new FindFormView
            {
                FormId = formId
            }.Send();
        }
        public void Generate ( long formId )
        {
            new GenerateFormView
            {
                FormId = formId
            }.Send();
        }
        public ViewBody GetBody ( long fromId )
        {
            return new GetFormViewBody
            {
                FormId = fromId
            }.Send();
        }

        public PagingResult<ExpandoObject> Query ( PagingParam<long> param )
        {
            return new QueryFormView
            {
                FormId = param.Query,
                Index = param.Index,
                Size = param.Size,
                SortName = param.SortName,
                IsDesc = param.IsDesc,
                NextId = param.NextId,
            }.Send();
        }

        public bool Set ( LongParam<FormViewSet> set )
        {
            return new SetFormView
            {
                Id = set.Id,
                Datum = set.Value
            }.Send();
        }
    }
}
